Component({
    properties: {
        header: {
            type: Object,
            value: {
                headerbg: "#FFFFFF",
                hiddenBlock: false,
            }
        },
        color:{
            type:String,
            value:'#ffffff'
        },
        title: {
            type: String,
            value: ''
        },
        type: {
            type: String,
            value: ''
        },

        reduce_TYPE: {
            type: Number,
            value: 0
        },
        show_pic:{
            type:Boolean,
            value:true
        },
        slot: {
            type:Boolean,
            value:true
        },
        back:{
            type:String,
            value:'/img/sign_back.png'
        },
        /**
         * 自定义返回事件处理
         * customBackReturn="{{true}}" bind:customBackReturn="customBackReturn"
         */
        customBackReturn: {
            type: Boolean,
            value: false
        }
    },
    methods: {
        backClick() {
            if (this.data.customBackReturn) {
                this.triggerEvent("customBackReturn")
            } else {
                if (getCurrentPages().length == 1) {
                    wx.switchTab({
                        url: '/pages/index/index',
                    })
                } else {
                    wx.navigateBack({
                        delta: 1
                    })
                }
            }
        },
        editClick() {
            let that = this;
            let reduce_TYPE = that.properties.reduce_TYPE == 0 ? 1 : 0
            that.setData({
                reduce_TYPE: reduce_TYPE
            })
            that.triggerEvent('changeType', {
                reduce_TYPE: that.properties.reduce_TYPE
            })
        },
        searchClick() {
            wx.navigateTo({
                url: '/pages/search/search',
            })
        },
        homeClick() {
            wx.switchTab({
                url: '/pages/index/index',
            })
        }
    },
    attached() {
        var self = this;
        wx.getSystemInfo({
            success(res) {
                var isIos = res.system.indexOf('iOS') > -1;
                self.setData({
                    statusHeight: res.statusBarHeight,
                    navHeight: isIos ? 44 : 48
                })
            }
        })
    }
})